home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
libs
/
tool6v12
/
tool6v12.doc
< prev
next >
Wrap
Text File
|
1994-07-01
|
70KB
|
1,707 lines
┌──────────────────────────────────────────────────────────────────────────────┐
│ ░░░░░░░░░░░░░ The "Complete" Borland Turbo Pascal 6.0 Toolbox ░░░░░░░░░░░░░░ │
├┬┬┬┬┬┬──────────────────────────────────────────────────────────────────┬┬┬┬┬┬┤
├┼┼┼┼┼┘ └┼┼┼┼┼┤
├┼┼┼┼┘ Version 1.2 └┼┼┼┼┤
├┼┼┼┘ └┼┼┼┤
├┼┼┘ Written by Thayne Breetzke Copyright (c) 1994, Sphinx Software └┼┼┤
├┼┘ └┼┤
└┴────────────────────────────────────────────────────────────────────────────┴┘
Contents
- ---──────────────────────────────────────────────────────────────────────--- -
INTRODUCTION
Introduction and legal stuff
How to use the Toolbox
Contacting the author
CURSOR ROUTINES
CursorOff
CursorOn
SaveCursorPos
RestoreCursorPos
SCREEN ROUTINES
CalcAttr
VideoMem
DisplayType
DisplayTypeDesc
VideoMode
VideoModeDesc
RowsOnScreen
ColsOnScreen
SaveArea
RestoreArea
ChangeAttr
ClearArea
WriteMem
WriteXY
SetVideoMode
ScrollUp
ScrollDown
ScrollRight
ScrollLeft
ScreenOn
ScreenOff
SetBorder
INPUT ROUTINES
WaitForKeypress
GetKey
ReadString
MOUSE ROUTINES
MouseLocate
SetHercGraph
MInstalled
MReset
MButtons
SetMouseLimit
SetMousePos
ShowMouse
HideMouse
ReadMouseMotion
ResetMouseMovement
ReadMouseMovement
MouseXCor
MouseYCor
ButtonPressed
AnyButtonPressed
GetPressInfo
GetReleaseInfo
SetSensitivity
GetSensitivity
SetGraphicsCursor
SoftwareTextCursor
HardwareTextCursor
MArea
STRING MANIPULATION ROUTINES
Spaces
Center
CopyChar
StrToNum
NumToStr
LeftTrim
RightTrim
Upper
Lower
BoolToStr
DATE/TIME ROUTINES
CountryCode
CountryDateFormat
CountryCurrency
CountryThouSep
CountryDecSep
CountryDateSep
CountryTimeSep
CountryCurrFormat
CountryTimeFormat
LeapYear
DaysinMonth
DayOfWeek
DayOfWeekDesc
DayofYear
MonthDesc
DateStr
ValidDate
TimeStr
SecondsToTime
WINDOW ROUTINES
WriteWinXY
WriteWinChar
OpenWindow
CloseWindow
DrawBox
VGA ROUTINES
FadeOut
FadeIn
GetPalette
SetPalette
WaitForRetrace
BIOS ROUTINES
WarmBoot
ColdBoot
SetTypematicRate
ResetTypematicRate
RShiftPressed
LShiftPressed
CtrlPressed
AltPressed
ScrollLockOn
NumLockOn
CapsLockOn
InsertOn
LCtrlPressed
LAltPressed
RCtrlPressed
RAltPressed
SysPressed
SuspendToggled
ScrollLockPressed
NumLockPressed
CapsPressed
InsertPressed
SetScrollLockOn
SetNumLockOn
SetCapsLockOn
SetInsertOn
SetScrollLockOff
SetNumLockOff
SetCapsLockOff
SetInsertOff
NumHardDisks
NumFloppies
ActiveFloppy
PrinterStatus
PrinterTimeOut
PrinterIOError
PrinterSelected
PrinterOutOfPaper
PrinterAcknowledge
PrinterNotBusy
MathCoPresent
DMAInstalled
NumSerialPorts
GameAdapterPresent
NumPrinterPorts
MICELLANEOUS ROUTINES
CommandLine
KeyBoardOff
KeyBoardOn
ClearKeyBuffer
CPUType
GetCPUSpeed
SetPauseOff
SetPauseOn
SetPrtScrOff
SetPrtScrOn
EDITOR ROUTINES
InitBuffer
FreeBuffer
ClearBuffer
EditText
LoadBuffer
SaveBuffer
FILE ROUTINES
Exists
LZH ROUTINES
InitLZHBuffers
FreeLZHBuffers
Encode
Decode
Introduction
- ---──────────────────────────────────────────────────────────────────────--- -
This toolbox was created to provide a wide variety of Turbo Pascal routines
for the Turbo Pascal programmer. Using them will eliminate all the messy bits
of code from your programs allowing you to focus on the programs' requirements.
The routines are very useful and easy to use and include mouse routines, string
manipulation routines, input routines, window routines, BIOS routines and more.
If you feel you would like a routine added, or have found any bugs (doubtful!),
or have any comments, feel free to mail me at the address below.
■ This software is free (yes, believe it or not!). You may distribute it freely
as long as you don't charge a fee for it. The units provided are for
evaluation purposes only. A garbled archive is included containing the
registered versions of the units. If you wish to continue using these units
please mail me at the address below stating your name and e-mail address and
I will send you a registration number which is to be entered as the password
when extracting the garbled archive. If you do not have an e-mail address you
must send your postal address. If you will be sending this information via
the postal service please include a self-addressed stamped envelope to allow
me to send you the registration number.
Thereafter, the software is yours. It's that simple. I would appreciate it if
you included my name in your programs that use these units.
This response will enable me to determine how popular the toolbox is. The
more response I receive the more encouraged I will be to continue to expand
and update it.
■ The author and any distributor of this software assumes no responsibility
for damages resulting from this software or its use due to errors, omissions,
incompatibility with other software or hardware, or misuse; and specifically
disclaim any implied warranty of fitness for any particular purpose or
application. Every care has been taken, however, to ensure that the routines
behave as stated.
■ Turbo Pascal is a registered trademark of Borland International, Inc.
USING THE TOOLBOX
To use the units in your own Turbo Pascal programs, simply include the name of
the required unit in the "uses" statement of your program. A detailed
explanation of each unit and its routines follows.
CONTACTING THE AUTHOR
The author can be contacted at the following addresses:
■ E-mail: 9216189@ml.petech.ac.za
■ Normal mail: Thayne Breetzke
7 Nahoon Valley Place
Nahoon Valley
East London
5241
South Africa
(Any donations may be sent to the above address - thanks...)
Note: You are REQUIRED to mail me to receive your registration
number for the garbled archive if you intend using this
software. (Hey, it's the least you could do!)
I welcome any comments or suggestions. Your support and
response will encourage me to continue to support this software.
CURSOR ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Cursor.tpu
PUBLIC DEFINITIONS
Type
CStateRec = Record
InsertKey,
CursorState: Boolean;
InsertType,
XCor,
YCor : Byte;
end;
{ This is the record used for storing the cursor state. }
Var
CursorState : Boolean;
{ Holds a TRUE value if the cursor is on; a FALSE value if it is off.
Used for reference only ie DO NOT ALTER THIS VALUE. Defaults to TRUE. }
InsertType : Byte;
{ A user-definable variable used for setting the cursor type. The effect
noticeable in insert mode only. 1 = Full-block cursor (default),
2 = Half-block cursor and 3 = Underscore cursor. }
Procedure CursorOff;
{ Turns the cursor off }
Procedure CursorOn(InsertKey: Boolean);
{ Turns the cursor on. Set InsertKey to TRUE to set it to insert mode,
or FALSE to set it to normal mode. }
Procedure SaveCursor(InsertKey: Boolean; Var CState: CStateRec);
{ Saves the cursor position, state and insert type. Set InsertKey to TRUE
if the cursor is in insert mode, else set it to FALSE. Useful for saving
the cursor position when opening a full-screen window at the start
of a program in order to restore the original DOS screen upon exiting.
Use RestoreCursorPos to restore the cursor (see below). A variable of
type CStateRec must be passed to hold the cursor state. }
Procedure RestoreCursor(CState: CStateRec);
{ Used to restore the cursor position, state and insert type after being
saved using SaveCursorPos (see above) using the cursor state record
provided. }
COMMENTS
These routines take the current video mode into consideration (eg hercules or
vga).
SCREEN ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Screen.tpu
PUBLIC DEFINITIONS
Function CalcAttr(FGround, BGround: Byte): Byte;
{ Calculates a colour using the FGround and BGround.
ie Colour = FGround + (BGround * 16) }
Function VideoMem: Word;
{ Returns the base address of video memory ie $B000 for monochrome card
and $B800 for graphics card. }
Function DisplayType: Byte;
{ Returns the type of display being used. Possible values are as follows:
DispType = $00 No display
$01 MDA with monochrome display
$02 CGA with colour display
$03 Reserved
$04 EGA with colour display
$05 EGA with monochrome display
$06 Professional graphics controller
$07 VGA with analog monochrome display
$08 VGA with analog colour display
$09 Reserved
$0A MCGA with digital colour display
$0B MCGA with analog monochrome display
$0C MCGA with analog colour display
$FF Unrecognized video system }
Function DisplayTypeDesc(DispType: Byte): String;
{ Returns a description of the type of display being used. See above for
the possible descriptions. }
Function VideoMode: Byte;
{ Returns the current video mode. Possible values are as follows:
VidMode = $00 40x25 B/W text (CGA,EGA,MCGA,VGA)
= $01 40x25 16 color text (CGA,EGA,MCGA,VGA)
= $02 80x25 16 shades of gray text (CGA,EGA,MCGA,VGA)
= $03 80x25 16 color text (CGA,EGA,MCGA,VGA)
= $04 320x200 4 color graphics (CGA,EGA,MCGA,VGA)
= $05 320x200 4 color graphics (CGA,EGA,MCGA,VGA)
= $06 640x200 B/W graphics (CGA,EGA,MCGA,VGA)
= $07 80x25 Monochrome text (MDA,HERC,EGA,VGA)
= $08 160x200 16 color graphics (PCjr)
= $09 320x200 16 color graphics (PCjr)
= $0A 640x200 4 color graphics (PCjr)
= $0B Reserved (EGA BIOS function 11)
= $0C Reserved (EGA BIOS function 11)
= $0D 320x200 16 color graphics (EGA,VGA)
= $0E 640x200 16 color graphics (EGA,VGA)
= $0F 640x350 Monochrome graphics (EGA,VGA)
= $10 640x350 16 color graphics (EGA or VGA with 128K)
640x350 4 color graphics (64K EGA)
= $11 640x480 B/W graphics (MCGA,VGA)
= $12 640x480 16 color graphics (VGA)
= $13 320x200 256 color graphics (MCGA,VGA)
= $8x EGA, MCGA or VGA ignore bit 7
= $9x EGA, MCGA or VGA ignore bit 7 }
Function VideoModeDesc(VidMode: Byte): String;
{ Returns a description of the current video mode. See above for the
possible descriptions. }
Function RowsOnScreen: Byte;
{ Returns the number of rows on the screen. }
Function ColsOnScreen: Word;
{ Returns the number of columns on the screen. }
Procedure SaveArea(X1,Y1,X2,Y2: Byte; Var ScrBuffer: ScrBufferRec);
{ Saves the specified area of a text screen. ScrBuffer is a variable
declared as ScrBufferRec (defined in this unit). You must use
RestoreArea before re-saving an area in the same variable to deallocate
memory. See below for a description of RestoreArea. }
Procedure RestoreArea(Var ScrBuffer: ScrBufferRec);
{ Restores the area previously saved in the specified variable using
SaveArea. }
Procedure SaveLine(YCor: Byte; Var TheString: String);
{ Saves the specified line of a text screen into TheString. If you save
a line without restoring it, the previously saved data will be
overwritten with the new data. }
Procedure RestoreLine(YCor: Byte; Var TheString: String);
{ Restores the previously saved line to the specified line of a text
screen, using the data in TheString. }
Procedure ChangeAttr(X1,Y1,X2,Y2,Colour: Word);
{ Changes the attributes of the specified area of a text screen to the
specified attribute (Colour). }
Procedure ClearArea(X1,Y1,X2,Y2,Colour: Byte; TheChar: Char);
{ Clears the specified area of a text screen, changing the attribute of
the area to the specified attribute (Colour) and fills the area with the
specified filler character (TheChar). }
Procedure WriteMem(X,Y: Byte; TheText: String);
{ Writes TheText directly to screen memory at position (X,Y). This is a
fast write routine. The attributes on the screen are not changed in any
way. }
Procedure WriteXY(X,Y: Byte; TheText: String; Colour: Byte);
{ Writes TheText to a text screen at position (X,Y) using the specified
attribute (Colour). }
Procedure SetVideoMode(VidMode: Byte);
{ Sets the video mode to the specified mode. Refer to the function
VideoMode above for a complete list of possible values for VidMode. }
Procedure ScrollUp(X1,Y1,X2,Y2,NumLines,Colour: Byte);
{ Scrolls the specified area of a text screen up NumLines lines using
the specified attribute (Colour) for the new bottom line. }
Procedure ScrollDown(X1,Y1,X2,Y2,NumLines,Colour: Byte);
{ Scrolls the specified area of a text screen down NumLines lines
using the specified attribute (Colour) for the new top line. }
Procedure ScrollRight(X1,Y1,X2,Y2,NumLines,Colour: Byte);
{ Scrolls the specified area of a text screen right NumLines lines
using the specified attribute (Colour) for the new line. }
Procedure Scrolleft(X1,Y1,X2,Y2,NumLines,Colour: Byte);
{ Scrolls the specified area of a text screen left NumLines lines
using the specified attribute (Colour) for the new line. }
Procedure ScreenOn;
{ Sets the screen on after being turned off using ScreenOff. }
Procedure ScreenOff;
{ Sets the screen off. Use ScreenOn to turn it back on. This is very
useful when drawing a screen, especially when the process is slow. Once
it is drawn the screen can turned to show the results instantly. }
Procedure SetBorder(Colour: Byte);
{ Sets the border colour to the specified colour. }
COMMENTS
To compute the Colour attribute use CalcAttr or perform the following:
Colour = Foreground + Background * 16
INPUT ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Input.tpu
PUBLIC DEFINITIONS
Type
CharSet = Set of Char;
Var
InsertKey: Boolean;
{ Holds a TRUE value if insert mode is active else a FALSE value if it
is not. }
Procedure WaitForKeypress;
{ Waits for a keypress. The keyboard buffer is flushed after a key is
pressed. }
Procedure GetKey(Var Key: Char; Var Extended: Boolean;
NormalKeys: CharSet; ExtendedKeys: CharSet;
DoWait: Boolean; DoUpdate: Boolean; UpdateProc: Routine;
UpdateVar: Word);
{ This routine's basic function is to get a keypress from the user. There
are a wide variety of parameters which make it a powerful routine. They
are as follows:
Key: Returns the key the user pressed (if one was pressed)
Extended: Returns TRUE if the key pressed was an extended key else
FALSE if it was not.
NormalKeys: This is a set of legal normal keys the user may press.
eg 'A',ENTER,SPACE.
ExtendedKeys: This is a set of legal extended keys the user may press.
eg F1,ALT-X,ALT-P.
DoWait: If TRUE is specified then the routine will wait for a
keypress else it will not.
DoUpDate: If TRUE is specified then the routine will execute the
update procedure specified as the last parameter of this
routine else it will not.
UpdateProc: This is the update routine that will be executed while
the routine waits for a keypress, provided that DoUpDate
was set to TRUE. This is a powerful feature added
recently to allow, for example, a clock to be displayed,
or to trap additional keys like F1 or ALT-X and execute
a procedure for each. Refer to the comments below with
regard to using this procedure.
UpdateVar: This variable is passed to the above UpdateProc. }
Procedure ReadString(Var InputString: String; X, Y, StringLength, BoxSize: Byte;
LegalChars: CharSet; UpperOnly: Boolean;
NormalEndChars: CharSet; ExtEndChars: CharSet;
Var TerminateChar: Char; Var Extended: Boolean;
DoUpdate, AtTheEnd: Boolean; Colour: Byte;
UpdateProc: Routine; UpdateVar: Word);
{ This routine accepts input from the user. The various parameters are
explained below:
InputString: This string hold the text to be edited or entered. Note
that if it contains a value, that value will be displayed
allowing the user to edited it. Therefore, assign this
field a '' value to allow the user to type a new value.
X: Specifies the X-position of the entry area.
Y: Specifies the Y-position of the entry area.
StringLength: Specifies the maximum number of characters the user is
allowed to enter.
BoxSize: Specifies the size of the entry area in characters plus
2. The BoxSize, for example, may be 24 while the
StringLength may be 200 allowing the user to enter 200
character within an area of 24 characters.
LegalChars: This is a set containing the legal characters the user may
enter.
UpperOnly: If TRUE is specified then all characters entered will be
changed to uppercase.
NormalEndChars: This is a set of legal normal keys the user may press to
end the input eg ENTER,CTRL-ENTER.
ExtEndChars: This is a set of legal extended keys the user may press
to terminate the input eg ALT-X,ALT-P.
TerminateChar: Returns the key the user pressed to terminate the input.
Extended: Returns TRUE if the terminate key was an extended key
else FALSE if it was not.
DoUpDate: If TRUE is specified then the routine will execute the
update procedure specified as the last parameter of this
routine else it will not.
AtTheEnd: If TRUE is specified the cursor will be positioned to
end of the string value to be edited else it will be
placed at the beginning.
Colour: Specifies the attribute to use for the data entry area.
UpdateProc: This is the update routine that will be executed while
the routine waits for a keypress, provided that DoUpDate
was set to TRUE. This is a powerful feature added
recently to allow, for example, a clock to be displayed,
or to trap additional keys like F1 or ALT-X and execute
a procedure for each. Refer to the comments below with
regard to using this procedure.
UpdateVar: This variable is passed to the above UpdateProc.
The following keys may be used during data input:
Left-arrow: Moves the cursor one position to the left.
Right-arrow: Moves the cursor one position to the right.
Home: Moves the cursor to the beginning of the entry area.
Repetitive presses will move it left BoxSize minus 2
characters.
End: Moves the cursor to the end of the entry area. Repetitive
presses will move it right BoxSize minus 2 characters.
Ctrl-Home: Moves the cursor to the beginning of the input string.
Ctrl-End: Moves the cursor to the end of the input string.
Backspace: Deletes the character to the left of the cursor.
Delete: Deletes the character beneath the cursor.
Insert: Toggles insert mode.
Ctrl-Y: Deletes the input string.
Ctrl-Left: Moves the cursor one word to the left.
Ctrl-Right: Moves the cursor one word to the right. }
COMMENTS
The UpdateProc must be defined in your program as follows:
{$F+}
Procedure UpdateProc(Var Key: Char; Var Extended: Boolean; UpdateVar: Word);
Begin
{ any other code is inserted here }
end;
{$F-}
Note that you may change the values that Key and Extended hold from within
UpdateProc if need be.
An example of a ReadString would be:
ReadString(InputString,5,5,200,24,[#0..#255],True,[#13,#10,#27,#45],[],
Key,Extended,True,False,112,UpdateProc,0);
A demonstration will more easily show what it does and how UpdateProc is
used. Refer to the demo files included.
MOUSE ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Mouse.tpu
PUBLIC DEFINITIONS
Type
Array32Word = Array[0..31] of Word;
{ Type for defining a graphics mouse cursor. }
Const
Hand : Array32word = ($ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,
$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,
$0000,$0000,$0700,$0500,$0500,$05FC,$0554,$0D54,
$1554,$1004,$0804,$0404,$0208,$0208,$0208,$0208);
{ A pre-defined graphics mouse cursor. }
INITIALIZING THE MOUSE
To be able to use the mouse, it must first be initialized.
Function MInstalled: Boolean;
{ The above function initializes the mouse and its software and returns
TRUE if a mouse is installed.
In addition the following is performed:
The mouse is positioned in the center of the screen.
The mouse cursor is reset and hidden.
The double speed threshold is set to 64 mickeys per second.
The horizontal mickey to pixel ratio is set (8 to 8).
The vertical mickey to pixel ratio is set (16 to 8).
The maximum width and height are set to maximum for the video mode.
Note: When using a graphics mode, first initialize the graphics mode
followed by the mouse. }
Function MReset: Boolean;
{ This function resets the mouse software, but not the mouse itself. It
returns TRUE if a mouse is installed. }
Function MButtons: Byte;
{ This function returns the number of buttons on the mouse (if
installed). }
Procedure SetMouseLimit(X1, X2, Y1, Y2: Integer);
{ This procedure sets the minimum and maximum horizontal and vertical
bounds. This enables you to limit the cursor movement to a certain
area. }
Procedure SetMousePos(X, Y: Integer);
{ Use this procedure to position the mouse cursor at the coordinates
(X,Y). }
Procedure ShowMouse;
{ This procedure shows the mouse cursor. }
OTHER FUNCTIONS AND PROCEDURES
Function MouseXCor: Integer;
{ This function returns the current x-coordinate of the mouse cursor. }
Function MouseYCor: Integer;
{ This function returns the current y-coordinate of the mouse cursor. }
Procedure ReadMouseMotion(Var Horiz, Vert: Integer);
{ This procedure returns the mouse motion counters. Horiz holds the
horizontal mickey count and Vert holds the vertical mickey count. Count
values are 1/200 inch intervals.
Procedure ResetMouseMovement;
{ This procedure must be called before the following procedure is called.
It must be called before each loop that uses ReadMouseMovement, as it
initializes variables used by the ReadMouseMovement procedure. See the
demonstration program included. }
Procedure ReadMouseMovement(Var Horiz, Vert: Integer);
{ This procedure returns the number of columns the mouse has been moved
horizontally (Horiz), and the number of rows the mouse has been moved
vertically (Vert). An upward direction returns a negative value in
Vert, a downward direction returns a positive value in Vert, a left
direction returns a negative value in Horiz, and a right direction
returns a positive value in Horiz. ResetMouseMovement must be
called before this procedure is used (see above). See the demonstration
program included. }
Procedure HideMouse;
{ This procedure hides the mouse cursor. }
Function ButtonPressed: Byte;
{ This function returns the last button pressed. }
Function AnyButtonPressed: Boolean;
{ This function returns TRUE if a mouse button has been pressed. }
Procedure GetPressInfo(Button: Byte; Var Presses, XCord, YCord: Integer);
{ This procedure returns data relating to button presses of the mouse.
The parameters are as follows:
Button: 0 for left button
1 for right button
Presses: Count of button presses (set to zero after call).
XCord: Horizontal position of mouse cursor at last press.
YCord: Vertical position of mouse cursor at last press. }
Procedure GetReleaseInfo(Button: Byte; Var Releases, XCord, YCord: Integer);
{ This procedure returns data relating to button releases of the mouse.
The parameters are as follows:
Button: 0 for left button
1 for right button
Releases: Count of button releases (set to zero after call).
XCord: Horizontal position of mouse cursor at last release.
YCord: Vertical position of mouse cursor at last release. }
Function MArea(X1, X2, Y1, Y2: Integer): Boolean;
{ This function returns TRUE if the mouse cursor is currently within the
specified area. }
Procedure GetSensitivity(Var HPixel, VPixel, Speed: Word);
{ This procedure returns the mouse sensitivity information as the number
of mouse coordinates per screen pixel. The parameters are as follows:
HPixel: Horizontal coordinates per pixel.
VPixel: Vertical coordinates per pixel.
Speed: Double speed threshold. }
Procedure SetSensitivity(HPixel, VPixel, Speed: Word);
{ This procedure sets the mouse sensitivity information as the number of
mouse coordinates per screen pixel. The parameters are as follows:
HPixel: Horizontal coordinates per pixel (the default is 8).
VPixel: Vertical coordinates per pixel (the default is 16).
Speed: Double speed threshold (the default is 64). }
Function MouseLocate(User-defined constant): Word;
{ This function uses a table of coordinates and returns a value indicating
which, if any, set of coordinates the mouse cursor is within.
The user-defined constant should be defined as follows:
Const
CorTable: Array[1..NumEntries,1..4] of Word =
((NumEntries,0,0,0),
(X1,X2,Y1,Y1)...);
For example: There are two options which the user may select by clicking
a mouse button. The horizontal position of the first ranges
from 352 to 504 and its vertical position is 80. The
horizontal position of the second option ranges from 352 to
488 and its vertical position is 96. The user-defined
constant should be defined as follows:
Const
CorTable: Array[1..3,1..4] of Word =
((3,0,0,0),
(352,504,80,80),
(352,488,96,96));
The function is called as follows:
Index := MouseLocate(CorTable);
Note: The maximum number of entries allowed in the table is 100. }
Procedure SetHercGraph;
{ Calling this procedure before the mouse is initialized ensures that the
mouse display routines operate correctly in hercules graphics mode. }
Procedure SetGraphicsCursor(HHotSpot,VHotSpot: Byte; MCursor: WordType);
{ This procedure selects a pre-defined graphics cursor. The parameters
are as follows:
HHotSpot: Horizontal hotspot.
VHotSpot: Vertical hotspot.
MCursor: Graphics cursor.
The unit has one pre-defined graphics cursor available. It is defined
as follows:
Const
Hand: Array32Word = ($ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,
$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,
$0000,$0000,$0700,$0500,$0500,$05FC,$0554,$0D54,
$1554,$1004,$0804,$0404,$0208,$0208,$0208,$0208);}
Procedure SoftwareTextCursor(ScreenMask,CursorMask: Word);
{ This procedure sets the software text cursor. }
Procedure HardwareTextCursor(FromScanLine,ToScanLine: Byte);
{ This procedure sets the hardware text cursor.
FromScanLine: Start of hardware scan line.
ToScanLine: End of hardware scan line. }
COMMENTS
A powerful mouse cursor designer is included with the registered version of
the toolbox. It was written using this mouse unit.
STRING MANIPULATION ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Strings.tpu
PUBLIC DEFINITIONS
Var
StringError: Integer;
{ Holds an error code if a string error occurred. }
Function Spaces(NumSpaces: Integer): String;
{ Returns a string containing the specified number of spaces. NumSpaces
must not be greater than 80. See CopyChar below. }
Function Center(TheString: String; MaxLength: Byte): String;
{ Centers the contents specified in TheString within the specified width
and returns the centered string as the function's result. If the
length of the string is greater than the specified width, StringError
will be set equivalent to: The strings length minus MaxLength. }
Function CopyChar(TheChar: Char; NumChars: Integer): String;
{ Replicates the specified character a specified number of times and
returns the resulting string as the result of the function. NumChars
must be less than 256. }
Function StrToNum(TheString: String): LongInt;
{ Converts a string to a LongInt. If an error occurs StringError will be
set indicating the position at which it occurred. }
Function NumToStr(Num:Real; Width, Decimals: Byte;
LeadingZeros: Boolean): String;
{ Converts the specified number to a string with the specified number of
decimals within a specified width to allow for right justification.
Set LeadingZeros to TRUE to set the filler character to a zero, else
FALSE to set it to a space. }
Function LeftTrim(TheString: String): String;
{ Trims all the spaces off the leftmost end of the specified string. }
Function RightTrim(TheString: String): String;
{ Trims all the spaces off the rightmost end of the specified string. }
Function Upper(TheString: String): String;
{ Converts the specified string to an upper case string. }
Function Lower(TheString: String): String;
{ Converts the specified string to a lower case string. }
Function BoolToStr(TheBool: Boolean; Defaults: String): String;
{ Converts a boolean value to a string. Defaults specifies the true/
false values the resulting string should inherit in that order. These
true/false values MUST be separated by a forward slash (/). The
following is an example of a possible default specification: 'Yes/No'. }
COMMENTS
None.
DATE/TIME ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: DateTime.tpu
PUBLIC DEFINITIONS
Type
Str4 = String[4];
Str2 = String[2];
Function CountryCode: Word;
{ Returns the country code from the country settings. The following are
the available country codes:
1: United States
2: French Canada
3: Latin America
31: Netherlands
32: Belgium
33: France
34: Spain
36: Hungary
38: Yugoslavia
39: Italy
41: Switzerland
42: Czechoslovakia
44: United Kingdom
45: Denmark
46: Sweden
47: Norway
48: Poland
49: Germany
55: Brazil
61: International English
81: Japan
82: Korea
86: China
90: Turkey
351: Portugal
354: Iceland
358: Finland
785: Saudi Arabia
972: Israel }
Function CountryDateFormat: Word;
{ Returns the country date format from the country settings. }
Function CountryCurrency: Str4;
{ Returns the country currency from the country settings. }
Function CountryThouSep: Char;
{ Returns the country thousand separator from the country settings. }
Function CountryDecSep: Char;
{ Returns the country decimal separator from the country settings. }
Function CountryDateSep: Char;
{ Returns the country date separator from the country settings. }
Function CountryTimeSep: Char;
{ Returns the country time separator from the country settings. }
Function CountryCurrFormat: Byte;
{ Returns the country currency format from the country settings. }
Function CountryTimeFormat: Byte;
{ Returns the country time format from the country settings. }
Function LeapYear(Year:Word): Boolean;
{ Returns a TRUE value if the year specified is a leap year, else FALSE. }
Function DaysInMonth(Month: Byte; Year: Word): Byte;
{ Returns the number of days in the specified month. }
Function DayOfWeek(Day,Month: Byte; Year: Integer): Byte;
{ Returns the day of week for the day, month and year combination
specified. }
Function DayOfWeekDesc(Day: Byte): String;
{ Returns the description for the specified day of the week. }
Function DayOfYear(Day,Month: Byte; Year: Word): Word;
{ Returns the day of the year for the day, month and year combination
specified. Valid for all years from 1901 to 2078. }
Function MonthDesc(Month: Byte): String;
{ Returns the description for the specified month of the year. }
Function DateStr(Day,Month: Byte; Year: Word; Format: Byte; DateSep: Char): String;
{ Formats the specified date according to the format specified using the
specified date separator. The formats supported are:
0: mm/dd/yy
1: dd/mm/yy
2: dd/mm/yyyy
3: mm/dd/yyyy
4: [d]d xxx yyyy (xxx is alpha month of 3 Chars)
5: xxx [d]d, yyyy
6: [d]d FullAlphaMth yyyy
7: FullAlphaMth [d]d, yyyy
8: [d]d-xxx-yy
9: xxx [d]d, 'yy }
Function ValidDate(Day,Month: Byte; Year: Word; Var ErrorCode: Byte): Boolean;
{ Returns a TRUE value if the date specified is a valid one. If it is
invalid, a relevant error code will be returned in ErrorCode as follows:
Year out of range (< 1901 or > 2078) bit 0 of errorcode is set.
Month < 1 or > 12 bit 1 of errorcode is set.
Day < 1 or > 31 bit 2 of errorcode is set.
Day out of range For month bit 2 of errorcode is set. }
Function TimeStr(Hour,Min,Sec,Format:Byte; TimeSep: Char): String;
{ Formats the specified time according to the format specified using the
specified time separator. The formats supported are:
0: hh:mm xx (xx is am or pm)
1: hh:mm
2: [h]h hours, [m]m minutes, [s]s seconds
3: [h]h hrs [m]m min [s]s sec
4: TotalSeconds
5: hh:mm:ss
6: [h]h:mm xx }
Function SecondsToTime(Seconds: LongInt; Format: Byte; TimeSep: Char): String;
{ Converts the specified number of seconds to a time using the specified
format and time separator. Refer to the procedure above, TimeStr, to
see the formats supported. }
COMMENTS
NOTE: Each value for Year MUST be a full value ie four digits eg 1994 not 94.
WINDOW ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Win.tpu
PUBLIC DEFINITIONS
Type
TitleStr = String[80];
FrameChars = Array[1..8] of Char;
WinState = Record
WindMin, WindMax: Word;
XCor,
YCor,
Attr: Byte;
end;
TitleStrPtr = ^TitleStr;
WinRecPtr = ^WinRec;
WinRec = Record
Next : WinRecPtr;
State : WinState;
Title,
Message : TitleStrPtr;
TitleAttr,
FrameAttr : Byte;
WinBuffer : Pointer;
end;
Const
SingleFrame: FrameChars = '┌─┐││└─┘';
DoubleFrame: FrameChars = '╔═╗║║╚═╝';
NoFrame : FrameChars = ' ';
Var
Ch : Char;
TopWindow : WinRecPtr;
WindowCount : Word;
{ The number of windows currently open }
procedure WriteWinXY(X, Y: Byte; S: String; Attr: Byte);
{ Writes the specified string at the specified position relative to the
window using the specified atttribute. }
procedure WriteWinChar(X, Y, Count: Byte; Ch: Char; Attr: Byte);
{ Copies the specified character Count times at the specified position
relative to the window using the specified attribute. }
Procedure OpenWindow(X1,Y1,X2,Y2: Byte; T: TitleStr; M: TitleStr;
DFrame: FrameChars; TAttr, FAttr: Byte; Border: Boolean);
{ Opens a window at the specified position (X1,Y1),(X2,Y2). Specify the
title of the window in parameter T and the message (to be displayed at
the bottom of the window) in parameter M. Specify the type of frame
in the DFrame parameter (SingleFrame, DoubleFrame, NoFrame). Specify
the text attribute in TAttr and the frame attribute in FAttr. Set
Border to TRUE if you require a shadow, else set to FALSE. }
Procedure CloseWindow;
{ Closes the last window opened. }
Procedure DrawBox(X1,Y1,X2,Y2: Byte; T: TitleStr; M: TitleStr;
DFrame: FrameChars; TAttr, FAttr: Byte; Border: Boolean);
{ The parameter are the same as for opening a window, see description for
OpenWindow. }
COMMENTS
None.
VGA ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Vga256.tpu
PUBLIC DEFINITIONS
Type
TRGB = record
Red, Green, Blue: Byte;
end;
PaletteType = Array[0..255] of TRGB;
{ Define all palette variables using this type }
Procedure FadeOut(Red, Green, Blue, Steps : Byte);
{ Fades the palette to the specified colours in a specified number of
steps. The smaller Steps is the faster the fade. }
Procedure FadeIn(Var Pal: PaletteType; Steps: Byte);
{ Fades the palette to the specified palette in a specified number of
steps. The smaller Steps is the faster the fade. }
Procedure GetPalette(Var Palette: PaletteType);
{ Stores the current 256 colour VGA palette in the specified variable. }
Procedure SetPalette(Var Palette: PaletteType);
{ Sets the 256 colour VGA palette to the specified palette bypassing BIOS.
BIOS. }
Procedure WaitForRetrace;
{ Waits for a vertical retrace to complete. Useful for reducing flicker. }
COMMENTS
These routines can be used for both text and graphics modes.
BIOS ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Bios.tpu
PUBLIC DEFINITIONS
Var
KeyFlag1 : Byte
{ Keyboard flag byte 1
│7│6│5│4│3│2│1│0│
│ │ │ │ │ │ │ └─── right shift key depressed
│ │ │ │ │ │ └──── left shift key depressed
│ │ │ │ │ └───── CTRL key depressed
│ │ │ │ └────── ALT key depressed
│ │ │ └─────── scroll-lock is active
│ │ └──────── num-lock is active
│ └───────── caps-lock is active
└────────── insert is active }
KeyFlag2 : Byte
{ Keyboard flag byte 2
│7│6│5│4│3│2│1│0│
│ │ │ │ │ │ │ └─── left CTRL key depressed
│ │ │ │ │ │ └──── left ALT key depressed
│ │ │ │ │ └───── system key depressed and held
│ │ │ │ └────── suspend key has been toggled
│ │ │ └─────── scroll lock key is depressed
│ │ └──────── num-lock key is depressed
│ └───────── caps-lock key is depressed
└────────── insert key is depressed }
KeyFlag3 : Byte
{ Keyboard flag byte 3
│7│6│5│4│3│2│1│0│ Keyboard mode/type
│ │ │ │ │ │ │ └─── last code was the E1 hidden code
│ │ │ │ │ │ └──── last code was the E0 hidden code
│ │ │ │ │ └───── right CTRL key depressed
│ │ │ │ └────── right ALT key depressed
│ │ │ └─────── 101/102 enhanced keyboard installed
│ │ └──────── force num-lock if Rd ID & KBX
│ └───────── last char was first ID char
└────────── read ID in process }
EquipFlag1: Byte
{ Equipment list flag 1
│7│6│5│4│3│2│1│0│
│ │ │ │ │ │ │ └─ IPL diskette installed
│ │ │ │ │ │ └── math coprocessor
│ │ │ │ ├─┼─── old PC system board RAM < 256K
│ │ │ │ │ └── pointing device installed (PS/2)
│ │ │ │ └─── not used on PS/2
│ │ └─┴──── initial video mode
└─┴─────── # of diskette drives, less 1 }
EquipFlag2: Byte
{ Equipment list flag 2
│7│6│5│4│3│2│1│0│
│ │ │ │ │ │ │ └─ 0 if DMA installed
│ │ │ │ └─┴─┴── number of serial ports
│ │ │ └─────── game adapter
│ │ └──────── not used, internal modem (PS/2)
└─┴───────── number of printer ports }
Procedure WarmBoot;
{ Warm boots the machine. }
Procedure ColdBoot;
{ Issues a disk reset (DOS function 0D) and cold boots the machine. Use
with caution. It is the programmer's responsiblility to ensure that
cache buffers are flushed. }
Procedure SetTypematicRate(TypeRate,TypeDelay: Byte);
{ Used on AT machines with extended keyboard support.
TypeDelay may be one of the following:
0 = 250ms 2 = 750ms
1 = 500ms 3 = 1000ms
TypeRate may be one of the following:
00 - 30.0 01 - 26.7 02 - 24.0 03 - 21.8
04 - 20.0 05 - 18.5 06 - 17.1 07 - 16.0
08 - 15.0 09 - 13.3 0A - 12.0 0B - 10.9
0C - 10.0 0D - 9.2 0E - 8.6 0F - 8.0
10 - 7.5 11 - 6.7 12 - 6.0 13 - 5.5
14 - 5.0 15 - 4.6 16 - 4.3 17 - 4.0
18 - 3.7 19 - 3.3 1A - 3.0 1B - 2.7
1C - 2.5 1D - 2.3 1E - 2.1 1F - 2.0 }
Procedure ResetTypematicRate;
{ Sets typematic rate to default. }
Function RShiftPressed: Boolean;
{ Returns TRUE if the right shift key is pressed, else FALSE. }
Function LShiftPressed: Boolean;
{ Returns TRUE if the left shift key is depressed, else FALSE. }
Function CtrlPressed: Boolean;
{ Returns TRUE if CTRL is depressed, else FALSE. }
Function AltPressed: Boolean;
{ Returns TRUE if ALT is depressed, else FALSE. }
Function ScrollLockOn: Boolean;
{ Returns TRUE if scroll lock mode is on, else FALSE. }
Function NumLockOn: Boolean;
{ Returns TRUE if number lock is on, else FALSE. }
Function CapsLockOn: Boolean;
{ Returns TRUE if caps lock is on, else FALSE. }
Function InsertOn: Boolean;
{ Returns TRUE if insert mode is on, else FALSE. }
Function LCtrlPressed: Boolean;
{ Returns TRUE if the left CTRL key is depressed, else FALSE. }
Function LAltPressed: Boolean;
{ Returns TRUE if the left ALT key is depressed, else FALSE. }
Function RCtrlPressed: Boolean;
{ Returns TRUE if the right CTRL key is depressed, else FALSE. }
Function RAltPressed: Boolean;
{ Returns TRUE if the right ALT key is depressed, else FALSE. }
Function SysPressed: Boolean;
{ Returns TRUE if the systems request key is depressed, else FALSE. }
Function SuspendToggled: Boolean;
{ Returns TRUE if suspend is toggled, else FALSE. }
Function ScrollLockPressed: Boolean;
{ Returns TRUE if the scroll lock key is depressed, else FALSE. }
Function NumLockPressed: Boolean;
{ Returns TRUE if the number lock key is depressed, else FALSE. }
Function CapsPressed: Boolean;
{ Returns TRUE if the caps lock key is depressed, else FALSE. }
Function InsertPressed: Boolean;
{ Returns TRUE if the insert key is depressed, else FALSE. }
Procedure SetScrollLockOn;
{ Sets scroll lock mode on. }
Procedure SetNumLockOn;
{ Sets number lock on. }
Procedure SetCapsLockOn;
{ Sets caps lock on. }
Procedure SetInsertOn;
{ Sets insert mode on. }
Procedure SetScrollLockOff;
{ Sets scroll lock mode off. }
Procedure SetNumLockOff;
{ Sets number lock mode off. }
Procedure SetCapsLockOff;
{ Sets caps lock off. }
Procedure SetInsertOff;
{ Sets insert mode off. }
Function NumHardDisks: Byte;
{ Returns the number of hard disks present. }
Function NumFloppies: Byte;
{ Returns the number of floppy drives present. }
Function ActiveFloppy: Byte;
{ Returns the active floppy. Useful for detecting if there is a phantom
drive present. 0 = A: and 1 = B: }
Function PrinterStatus(Port: Word): Byte;
{ Returns the current printer status byte. Note that not all printers
return reliable status information; bit 3 and bit 7 are usually
reliable.
│7│6│5│4│3│2│1│0│
│ │ │ │ │ │ │ └──── time-out
│ │ │ │ │ └─┴───── unused
│ │ │ │ └──────── 1 = I/O error (parallel pin 15)
│ │ │ └───────── 1 = printer selected/on-line (parallel pin 13)
│ │ └────────── 1 = out of paper (parallel pin 12)
│ └─────────── 1 = printer acknowledgment (parallel pin 10)
└──────────── 1 = printer not busy (parallel pin 11) }
Function PrinterTimeOut(Port: Word): Boolean;
{ Returns TRUE if printer has timed out, else FALSE. }
Function PrinterIOError(Port: Word): Boolean;
{ Returns TRUE if a printer I/O error has occurred, else FALSE. }
Function PrinterSelected(Port: Word): Boolean;
{ Returns TRUE if the printer is selected, else FALSE. }
Function PrinterOutOfPaper(Port: Word): Boolean;
{ Returns TRUE if the printer is out of paper, else FALSE. }
Function PrinterAcknowledge(Port: Word): Boolean;
{ Returns TRUE if the printer is acknowledged, else FALSE. }
Function PrinterNotBusy(Port: Word): Boolean;
{ Returns TRUE if the printer is not busy, else FALSE. }
Function MathCoPresent: Boolean;
{ Returns TRUE if a math co-processor is present, else FALSE. }
Function DMAInstalled: Boolean;
{ Returns TRUE if DMA is installed, else FALSE. }
Function NumSerialPorts: Byte;
{ Returns the number of serial ports. }
Function GameAdapterPresent: Boolean;
{ Returns TRUE is a game adapter is present, else FALSE. }
Function NumPrinterPorts: Byte;
{ Returns the number of printer ports. }
COMMENTS
None.
MISCELLANEOUS ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Misc.tpu
PUBLIC DEFINITIONS
Function CommandLine: String;
{ Returns the command line following the program name. }
Procedure KeyBoardOff;
{ Turns the keyboard off. }
Procedure KeyBoardOn;
{ Turns the keyboard on. }
Procedure ClearKeyBuffer;
{ Clears the keyboard buffer. }
Function CPUType: Byte;
{ Returns the CPU type for the current machine. CPUType will be one of
the following:
1 = 8086
2 = 80286
3 = 80386
4 = 80486 }
Procedure GetCPUSpeed(Var Mhz, KHz: Word);
{ Returns an estimate of the CPU speed of the current machine into the
specified variables. }
Procedure SetPauseOff;
{ Latches onto the timer interrupt ($08) to enable pause presses to be
ignored. }
Procedure SetPauseOn;
{ Restores the timer interrupt ($08). Used after previously setting
pause off using SetPauseOff. }
Procedure SetPrtScrOff;
{ Latches onto the print-screen interrupt ($05) to enable print screen
presses to be ignored. }
Procedure SetPrtScrOn;
{ Restores the print-screen interrupt ($05). Used after previously
setting print screen off using SetPrtScrOff. }
COMMENTS
None.
EDITOR ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Editor.tpu
PUBLIC DEFINITIONS
Type
BuffType = Array[1..1] of Char;
BuffPtr = ^BuffType;
BufferRec = Record
Buff : BuffPtr; { The buffer }
BuffSize, { Set when the buffer is initialized }
TextSize : Word; { The size of the text in the buffer }
ChangesMade: Boolean; { Holds a TRUE value if the text has }
{ changed else FALSE if it has not. }
end;
BufferPtr = ^BufferRec;
PosType = (AtStart,AtEnd,AsIs);
Var
Buffer: BufferPtr;
Procedure InitBuffer(Var Buffer: BufferPtr; Size: Word);
{ Allocates the specified amount of bytes of buffer memory to the
specified buffer, initializes its variables and sets ChangesMade to
FALSE. This procedure MUST be called before the editor is called. }
Procedure FreeBuffer(Var Buffer: BufferPtr);
{ Deallocates the memory allocated to the specified buffer. }
Procedure ClearBuffer(Var Buffer: BufferPtr);
{ Empties the buffer and resets it's variables. It does not affect then
ChangesMade variable. }
Procedure EditText(Var Buffer: BufferPtr; X1,Y1,BoxLength,
BoxDepth: Byte; LegalChars: CharSet; UpperOnly: Boolean;
NormalEndChars: CharSet; ExtEndChars: CharSet;
Var TerminateChar: Char; Var Extended: Boolean;
DoUpdate: Boolean; Position: PosType; Initialize: Boolean;
UpdateProc: Routine);
{ Calls the editor and edits the text in the specified buffer. The various
parameters are explained below:
Buffer: The buffer containing the text to be edited.
X1: The X-position of the top-left corner of the edit window.
Y1: The Y-position of the top-left corner of the edit window.
BoxLength: The length of the edit window.
BoxDepth: The depth of the edit window.
LegalChars: This is a set containing the legal characters the user
may enter.
UpperOnly: If TRUE is specified then all characters entered will be
changed to uppercase.
NormalEndChars: This is a set of legal normal keys the user may press to
terminate the editing eg ENTER,CTRL-ENTER.
ExtEndChars: This is a set of legal extended keys the user may press
to terminate the editing eg ALT-X,ALT-P.
TerminateChar: Returns the key the user pressed to terminate the
editing.
Extended: Returns TRUE if the terminate key was an extended key
else FALSE if it was not.
DoUpDate: If TRUE is specified then the routine will execute the
update procedure specified as the last parameter of this
routine else it will not.
Position: Position can be one of three values: AtStart, AtEnd or
AsIs. AtStart causes the beginning of the text to be
displayed initially, AtEnd causes the end of the text to
be displayed initially and AsIs causes the text to be
displayed as it was last.
Initialize: If TRUE is specified then the ClearBuffer procedure will
be called automaticaly before editing commences.
UpDateProc: This is the update routine that will be executed while
the routine waits for a keypress, provided that DoUpDate
was set to TRUE. This is a powerful feature added
recently to allow, for example, a clock to be displayed,
or to trap additional keys like F1 or ALT-X and execute
a procedure for each. Refer to the comments for the
'Input Routines' section.
The following keys may be used during data input:
Up-Arrow: Moves the cursor one line up.
Down-Arrow: Moves the cursor one line down.
Left-Arrow: Moves the cursor one position to the left.
Right-Arrow: Moves the cursor one position to the right.
Home: Moves the cursor to the beginning of the line.
End: Moves the cursor to the end of the line.
Page-Up: Moves the cursor one page up.
Page-Down: Moves the cursor one page down.
Ctrl-Home: Moves the cursor to the beginning of the text.
Ctrl-End: Moves the cursor to the end of the text.
Ctrl-Left: Moves the cursor to the beginning of the previous word.
Ctrl-Right: Moves the cursor to the beginning of the next word.
Tab: Tabs the cursor to the right (does not insert a TAB
character).
Shift-Tab: Tabs the cursor to the left (does not insert a TAB
character).
Insert: Toggles insert mode.
Backspace: Deletes the character to the left of the cursor.
Delete: Deletes the character beneath the cursor.
Ctrl-Y: Deletes the current line.
Ctrl-E: Deletes from the current line to the end of the text.
Ctrl-C: Centers the current line.
Enter: Moves the cursor to the next line (insert mode off).
Enter: Inserts a line (insert mode on).
The ChangesMade variable for the specified buffer is set to TRUE if any changes
are made to the text. This variable can be changed by the programmer as can
Buff and TextSize. Do NOT alter BuffSize as it is for reference only. You
may alter the buffer contents as long as TextSize is altered accordingly and
that it is done before or after EditText is called - not from within it. }
Procedure LoadBuffer(Var Buffer: BufferPtr; FileName: String;
Var ErrorCode: Integer);
{ Loads the specified file into the buffer and returns IOResult to the
ErrorCode variable. This procedure checks for all I/O errors and
returns the result and therefore won't crash at any point. If the file
is too large to fit into the buffer, it will load as much as it can and
return an ErrorCode of 255 (file to large, only partially read). }
Procedure SaveBuffer(Var Buffer: BufferPtr; FileName: String;
Var ErrorCode: Integer);
{ Saves the buffer to the specified file and returns IOResult to the
ErrorCode variable. This procedure checks for all I/O errors and
returns the result and therefore won't crash at any point. }
COMMENTS
The maximum buffer size which can be specified is 65,535. I have not found a
need for a buffer size greater than this, but am considering increasing this
limit.
FILE ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Files.tpu
PUBLIC DEFINITIONS
Function Exists(FileName: String): Boolean;
{ Returns TRUE if the specified file exists else returns FALSE. }
COMMENTS
This unit is still under development.
LZH ROUTINES
- ---──────────────────────────────────────────────────────────────────────--- -
UNIT NAME: Lzh.tpu
PUBLIC DEFINITIONS
Procedure InitLZHBuffers(BufferSize: Word);
{ Allocates the internal buffers to be used to compress and decompress
data. BufferSize specifies the size of the buffers to be used. This
procedure MUST be called before the following are used. }
Procedure FreeLZHBuffers;
{ De-allocates the buffers allocated using the InitLZHBuffers procedure. }
Procedure Encode(ReadRoutine: Routine; WriteRoutine: Routine;
Bytes: LongInt);
{ Encodes data using the program-defined read routine and write routine.
Bytes specifies the number of Bytes to encode. By allowing the
programmer to specify the read and write routines provides much
flexibility. Disk files can the read, encoded, and written to disk;
read, and encoded directly into a memory variable; read, decoded, and
written to disk; read, and decoded directly into a memory variable. See
the demonstration provided to see how these program-specified routines
are used. }
Procedure Decode(ReadRoutine: Routine; WriteRoutine: Routine);
{ Behaves in the same way as Encode, except that the data is decoded. The
number of bytes to be decoded is not specified. See the demonstration
program provided to see how the program-specified routines are used. }
COMMENTS
Refer to the demonstration program provided (DEMOLZH.EXE).
REVISIONS
- ---──────────────────────────────────────────────────────────────────────--- -
Version 1.1 20 April 1994
■ Fixed a bug in the Windows unit - WindowCount was not initially initialized
to zero.
■ WriteXY no longer adjusts the current cursor position
■ Added two routines to the Screen unit: SaveLine and RestoreLine.
■ Modifed SaveArea and RestoreArea to allow the saving and restoring using
program-defined variables.
■ Modified the OpenWindow and DrawBox routines so as to use the frame
attribute for titles and messages.
■ Fixed minor memory de-allocation bug in the window routine.
■ Included a new unit allowing for LZH-type compression and decompression.
■ Modified GetKey and ReadKey to allow a value to be passed to UpdateProc.
■ Modified SaveCursorPos and RestoreCursorPos to allow for multiple saving
of cursor states.
■ Modified the save and restore cursor routines to enable RestoreCursor to
set the cursor on or off automatically.
Version 1.2 1 July 1994
■ Modified the Windows unit - window titles are now placed on the window
frame in the best possible position, regardless of the lengths of the titles
or whether a shadow is used.
■ Added two very useful routines to the Mouse unit to allow for the reading of
mouse movement. These routines differ to that of the ReadMouseMotion
routine.
■ My apologies to those who tried to re-compile the demonstration programs but
couldn't. I forgot to update one or two of them. Each has been compiled
using the modified units and each has been tested.
THANKS TO
- ---──────────────────────────────────────────────────────────────────────--- -
■ All those who have responded both positively (and negatively).
■ Brad Meier for his suggestions given.
■ Those who have registered their copies of the toolbox.
NEW VERSIONS
- ---──────────────────────────────────────────────────────────────────────--- -
New versions of the toolbox can be found at the following sites:
■ ftp.sun.ac.za (not at present)
■ ftp.uwp.edu (not at present)
■ ftp.wustl.edu (/pub/MSDOS_UPLOADS/programming/pascal/TOOL6Vxx.ARJ)
LOOK OUT FOR OTHER SOFTWARE FROM THE SAME AUTHOR
- ---──────────────────────────────────────────────────────────────────────--- -
>>> The Turbo Pascal 6.0 Help File Creator <<<
Create on-line help for your Turbo Pascal programs in an extremely fast,
efficient and user-friendly manner and eliminate all the messy bits of code from
your programs when coding on-line help. You are also able to to create on-line
manuals or anything of a similar nature. In this case no Turbo Pascal knowledge
is necessary.
A demo version of HFC can be acquired from:
■ the following internet site:
ftp.wustl.edu (/pub/MSDOS_UPLOADS/programming/pascal/HFC6Vxx.ARJ) using FTP
■ the following South African BBS (East London):
A & M ONLINE (56654)
- ---──────────────────────────────────────────────────────────────────────--- -